<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>定时器动画</title>
	<style type="text/css">
		.box{
			width: 100px;
			height: 100px;
			background-color: gold;
			position: fixed;
			left: 20px;
			top: 20px;
		}


	</style>
	<script type="text/javascript">
		
		window.onload = function(){

			var oBox = document.getElementById('box');

			var left = 20;

			// 重复计时
			var timer = setInterval(function(){

				left++;
				oBox.style.left = left + 'px';

				if(left>700){

					// 关闭定时器
					clearInterval(timer);
				}

			},30)
		}
	</script>
</head>
<body>
	<div class="box" id="box"></div>
</body>
</html>